﻿namespace SDKHKApp.SDK
{
    /// <summary>
    /// 相机通用接口
    /// </summary>
    public interface ICamera : IDisposable
    {
        #region 变量属性
        /// <summary>
        /// 定义相机的序列号
        /// </summary>
        public string SN { get; set; }
        /// <summary>
        /// 定义图像采集对应委托所属性
        /// </summary>
        public Action<string, Bitmap> ActionGetImage { get; set; }
        #endregion

        #region  相机操作
        /// <summary>
        /// 获取相机SN枚举
        /// </summary>
        /// <returns></returns>
        List<string> GetListEnum();

        /// <summary>
        /// 初始化相机
        /// </summary>
        /// <param name="CamSN"></param>
        /// <returns></returns>
        bool InitDevice(string CamSN);

        /// <summary>
        /// 注销相机
        /// </summary>
        bool CloseDevice();

        /// <summary>
        /// 软触发模式 启动相机
        /// </summary>
        /// <returns></returns>
        bool StartWith_SoftTriggerModel();

        /// <summary>
        /// 硬触发模式 启动相机
        /// </summary>
        /// <param name="hardtriggeritem"></param>
        /// <returns></returns>
        bool StartWith_HardTriggerModel(TriggerSource hardtriggeritem);

        /// <summary>
        /// 等待硬触发获取图像
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="outtime"></param>
        /// <returns></returns>
        bool GetImage(out Bitmap bitmap, int outtime = 3000);

        /// <summary>
        /// 软触发获取图像
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="outtime"></param>
        /// <returns></returns>
        bool GetImageWithSoftTrigger(out Bitmap bitmap, int outtime = 3000);

        /// <summary>
        /// 软触发
        /// </summary>
        /// <returns></returns>
        bool SoftTrigger();
        #endregion

        #region 图像采集
        /// <summary>
        /// 停止采集
        /// </summary>
        /// <returns></returns>
        bool StopGrabbing();
        /// <summary>
        /// 开始录像
        /// </summary>
        /// <returns></returns>
        bool StartRecord();
        /// <summary>
        /// 停止录像
        /// </summary>
        /// <returns></returns>
        bool StopRecord();
        #endregion

        #region 图像保存
        /// <summary>
        /// 保存Bmp图像
        /// </summary>
        /// <returns></returns>
        bool SaveBmp();
        /// <summary>
        /// 保存Jpg图像
        /// </summary>
        /// <returns></returns>
        bool SaveJpg();
        /// <summary>
        /// 保存Png图像
        /// </summary>
        /// <returns></returns>
        bool SavePng();
        /// <summary>
        /// 保存Tiff图像
        /// </summary>
        /// <returns></returns>
        bool SaveTiff();
        #endregion

        #region 设置相机配置
        /// <summary>
        /// 设置相机参数
        /// </summary>
        /// <param name="config"></param>
        void SetCamConfig(CamConfig config);
        /// <summary>
        /// 获取相机参数
        /// </summary>
        /// <param name="config"></param>
        void GetCamConfig(out CamConfig config);

        /// <summary>
        /// 设置触发模式及触发源
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="triggerEnum"></param>
        /// <returns></returns>
        bool SetTriggerMode(TriggerMode mode, TriggerSource triggerEnum = TriggerSource.Line0);

        /// <summary>
        /// 获取触发模式及触发源
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="hardTriggerModel"></param>
        /// <returns></returns>
        bool GetTriggerMode(out TriggerMode mode, out TriggerSource hardTriggerModel);

        /// <summary>
        /// 设置曝光时长
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        bool SetExpouseTime(float value);

        /// <summary>
        /// 获取曝光时长
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        bool GetExpouseTime(out float value);

        /// <summary>
        /// 设置硬触发极性
        /// </summary>
        /// <param name="polarity"></param>
        /// <returns></returns>
        bool SetTriggerPolarity(TriggerPolarity polarity);

        /// <summary>
        /// 获取硬触发极性
        /// </summary>
        /// <param name="polarity"></param>
        /// <returns></returns>
        bool GetTriggerPolarity(out TriggerPolarity polarity);

        /// <summary>
        /// 设置触发滤波时间 （us）
        /// </summary>
        /// <param name="flitertime"></param>
        /// <returns></returns>
        bool SetTriggerFliter(float flitertime);

        /// <summary>
        /// 获取触发滤波时间 （us）
        /// </summary>
        /// <param name="flitertime"></param>
        /// <returns></returns>
        bool GetTriggerFliter(out float flitertime);

        /// <summary>
        /// 设置触发延时
        /// </summary>
        /// <param name="delay"></param>
        /// <returns></returns>
        bool SetTriggerDelay(float delay);

        /// <summary>
        /// 获取触发延时
        /// </summary>
        /// <param name="delay"></param>
        /// <returns></returns>
        bool GetTriggerDelay(out float delay);

        /// <summary>
        /// 设置增益
        /// </summary>
        /// <param name="gain"></param>
        /// <returns></returns>
        bool SetGain(float gain);

        /// <summary>
        /// 获取增益值
        /// </summary>
        /// <param name="gain"></param>
        /// <returns></returns>
        bool GetGain(out float gain);

        /// <summary>
        /// 获取帧率
        /// </summary>
        /// <param name="gain"></param>
        /// <returns></returns>
        bool GetFrameRate(out float frameRate);

        /// <summary>
        /// 设置帧率
        /// </summary>
        /// <param name="gain"></param>
        /// <returns></returns>
        bool SetFrameRate(float frameRate);

        /// <summary>
        /// 获取像素格式
        /// </summary>
        /// <param name="pixelFormats"></param>
        /// <returns></returns>
        bool GetPixelFormat(out List<string> pixelFormats);

        /// <summary>
        /// 设置信号线模式
        /// </summary>
        /// <param name="line"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        bool SetLineMode(IOLines line, LineMode mode);

        /// <summary>
        /// 设置信号线电平状态
        /// </summary>
        /// <param name="line"></param>
        /// <param name="linestatus"></param>
        /// <returns></returns>
        bool SetLineStatus(IOLines line, LineStatus linestatus);

        /// <summary>
        /// 获取信号线电平状态
        /// </summary>
        /// <param name="line"></param>
        /// <param name="lineStatus"></param>
        /// <returns></returns>
        bool GetLineStatus(IOLines line, out LineStatus lineStatus);

        /// <summary>
        /// 自动白平衡
        /// </summary>
        /// <returns></returns>
        bool AutoBalanceWhite();

        #endregion
    }
}
